<?php

namespace App\Http\Controllers\Shop;

use App\Http\Controllers\Controller;
use App\Service\ShopService;
use Illuminate\Http\Request;

class GoodsController extends Controller
{
    /**
     * goodsList 商品列表
     * @time:2020/3/14-16:24
     *  商品列表 分页, 搜索
     * @author:dongdong
     * @queryParam example_id required The id of the location.
     * @bodyParam example_id required The id of the location.
     * @response {
     * "data": {
     * },
     * "status_code": 200,
     * "message" : "success"
     * }
     */
    public function goodsList(Request $request)
    {
        $request->validate([
            'class_id' => 'nullable|exists:goods_class,id',
        ]);
        $search = $request->get('search','');
        $limit = $request->get('limit',15);
        $classId = $request->get('class_id',0);

        $data = (new ShopService())->search($limit, $search,$classId);
        return returnData($data);
    }


}
